<?php
// +----------------------------------------------------------------------
// | zhanshop-marketing / TestWriteAdlisten.php    [ 2024/12/23 16:04 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2011~2024 zhangqiquan All rights reserved.
// +----------------------------------------------------------------------
// | Author: zhangqiquan <768617998@qq.com>
// +----------------------------------------------------------------------
declare (strict_types=1);

namespace app\console;

use zhanshop\console\Command;
use zhanshop\console\Input;
use zhanshop\console\Output;
use zhanshop\client\Httpclient;
use zhanshop\Helper;

class TestWriteAdlisten extends Command
{
    public function configure()
    {
        $this->useDatabase()->setTitle("写入测试广告检测")->setDescription('测试广告检测数据写入');
    }

    public function execute(Input $input, Output $output)
    {
        var_dump(Helper::symmetryEncode("1"));
        $platform = $input->input("platform", "请输入测试平台, 可选值(vivo,huawei,xiaomi,oppo,byte,baidu,honor)");
        $this->$platform();
    }

    public function vivo()
    {
        $data = array (
            'adId' => time(),
            'adName' => '测试-普通投放-推荐',
            'advertisementId' => 2222,
            'advertiserId' => '123456',
            'advertiserName' => 'TEST',
            'av' => '8',
            'campaignId' => 12042077,
            'campaignName' => '测试-普通投放-推荐列表',
            'cfrom' => 0,
            'clickTime' => 1734920601343,
            'creativeId' => 112924028,
            'groupId' => 14143409,
            'groupName' => '测试-推荐-普通投放',
            'imei' => md5(date('Y-m-d H:i')),
            'ip' => rand(1, 255).'.'.rand(1, 255).'.'.rand(1, 255).'.'.rand(1, 255),
            'mediaType' => 0,
            'placeType' => 20,
            'requestId' => '1734920598271_'.md5(strval(microtime(true))),
            'ts' => time(),
        );

        $curl = new Httpclient();
        $curl->setHeader('Content-Type', 'application/json');
        $url = 'http://127.0.0.1:7201/v1/ad.listen/luyin/vivo/click/LeekAh0z8ri2X5zp2scDYARiPHulRhDk867bOY2CEpk_3D?pkg_name=com.rbt.audiotxt&src_type=APP&src_id=ds-202412178977';
        $resp = $curl->request($url, "POST", [$data]);
        if($resp['body']){
            $json = json_decode($resp['body'], true);
            if($json) $resp['body'] = $json;
        }
        $resp['url'] = $url;
        print_r($resp);
    }

    public function huawei()
    {
        $data = array (
            'aid' => '00000',
            'aid_name' => 'zhanshop_应用搜索_系统投放_000000',
            'app_id' => '000000',
            'app_name' => 'zhanshop',
            'channel_name' => '',
            'channel_id' => '',
            'group_name' => '',
            'group_id' => '',
            'oaid' => md5(date('Y-m-d H:i')),
            'id_type' => '',
            'unique_id' => '',
            'action_type' => 'IMP',
            'ts' => time(),
            'callback' => 'security:0000000000:A4668E33'.sha1(strval(microtime(true))),
            'sub_taskid' => time(),
            'rtaid' => '__RTAID',
        );
        $curl = new Httpclient();
        $curl->setHeader('Content-Type', 'application/json');
        $url = 'http://127.0.0.1:7201/v1/ad.listen/zhanshop/huawei/click/CEgm1pj2JXNmnlEI1gn2JdHryzcsHbxq1huin_2BlBvDM_3D';
        $resp = $curl->request($url.'?'.http_build_query($data));
        if($resp['body']){
            $json = json_decode($resp['body'], true);
            if($json) $resp['body'] = $json;
        }
        $resp['url'] = $url;
        print_r($resp);



        $data = array (
            'aid' => '00000',
            'aid_name' => 'zhanshop_应用搜索_系统投放_000000',
            'app_id' => '000000',
            'app_name' => 'zhanshop',
            'channel_name' => '',
            'channel_id' => '',
            'group_name' => '',
            'group_id' => '',
            'oaid' => md5(date('Y-m-d H:i')),
            'id_type' => 0,
            'unique_id' => md5(date('Y-m-d H:i')),
            'action_type' => 'IMP',
            'ts' => time(),
            'callback' => 'security:0000000000:A4668E33'.sha1(strval(microtime(true))),
            'sub_taskid' => time(),
            'rtaid' => '__RTAID',
        );
        $curl = new Httpclient();
        $curl->setHeader('Content-Type', 'application/json');
        $url = 'http://127.0.0.1:7201/v1/ad.listen/zhanshop/huawei/click/CEgm1pj2JXNmnlEI1gn2JdHryzcsHbxq1huin_2BlBvDM_3D';
        $resp = $curl->request($url.'?'.http_build_query($data));
        if($resp['body']){
            $json = json_decode($resp['body'], true);
            if($json) $resp['body'] = $json;
        }
        $resp['url'] = $url;
        print_r($resp);
    }

    public function xiaomi()
    {
        $data = array (
            'response_validate' => false,
            'imei' => md5(date('Y-m-d H:i')),
            'imei2' => '000000',
            'meid' => 'zhanshop',
            'oaid' => md5(date('Y-m-d H:i')),
            'click_time' => "123456",
            'app_id' => "123456",
            'adid' => "123456",
            'campaign_id' => "123456",
            'customer_id' => '123456',
            'callback' => '123456',
            'sign' => '123456',
            'expId' => '123456',
            'ip' => rand(1, 255).'.'.rand(1, 255).'.'.rand(1, 255).'.'.rand(1, 255),
            'ua' => "aaaaaaaaaaa",
            'androidId' => '123456',
            'adName' => '123456',
            'rtaExpId' => '123456',
        );

        $curl = new Httpclient();
        $curl->setHeader('Content-Type', 'application/json');
        $url = 'http://127.0.0.1:7201/v1/ad.listen/zhanshop/xiaomi/click/CEgm1pj2JXNmnlEI1gn2JdHryzcsHbxq1huin_2BlBvDM_3D';
        $resp = $curl->request($url.'?'.http_build_query($data));
        if($resp['body']){
            $json = json_decode($resp['body'], true);
            if($json) $resp['body'] = $json;
        }
        $resp['url'] = $url;
        print_r($resp);
    }

    public function oppo()
    {
        $data = array (
            "bundle" => "cn.zhanshop",
            'ad' => '000000',
            'imei' => md5(date('Y-m-d H:i')),
            'oaid' => '000000',
            'ts' => 'zhanshop',
            'android_id' => md5(date('Y-m-d H:i')),
            'ip' => rand(1, 255).'.'.rand(1, 255).'.'.rand(1, 255).'.'.rand(1, 255),
            'ua' => "123456",
            'owner_id' => "123456",
            'plan_id' => "123456"
        );

        $curl = new Httpclient();
        $curl->setHeader('Content-Type', 'application/json');
        $url = 'http://127.0.0.1:7201/v1/ad.listen/zhanshop/oppo/click/CEgm1pj2JXNmnlEI1gn2JdHryzcsHbxq1huin_2BlBvDM_3D';
        $resp = $curl->request($url.'?'.http_build_query($data));
        if($resp['body']){
            $json = json_decode($resp['body'], true);
            if($json) $resp['body'] = $json;
        }
        $resp['url'] = $url;
        print_r($resp);
    }

    public function byte()
    {
        $ipv4 = rand(1, 255).'.'.rand(1, 255).'.'.rand(1, 255).'.'.rand(1, 255);
        $data = array (
            'promotion_id' => '7451000000',
            'project_id' => '7451000000',
            'promotion_name' => '测试广告',
            'project_name' => '12-23',
            'mid1' => '0',
            'mid2' => '730459175000000',
            'mid3' => '742564615000000',
            'mid4' => '0',
            'mid5' => '74280722089000000',
            'mid6' => '74515503635000000',
            'aid' => '181922623848000000',
            'aid_name' => 'cdp_promotion_74515506674000000',
            'cid' => '1819226439000000',
            'cid_name' => '',
            'campaign_id' => '18192246551000000',
            'campaign_name' => 'cdp_project_7451544184427000000',
            'ctype' => '15',
            'advertiser_id' => '1812675731000000',
            'csite' => '40000',
            'convert_id' => '0',
            'request_id' => '202412240329124E4E87BD000000',
            'track_id' => '828e27fd536000000',
            'sl' => 'zh',
            'imei' => '',
            'idfa' => '',
            'idfa_md5' => '',
            'android_id' => md5(date('Y-m-d H:i:s')),
            'oaid' => md5(date('Y-m-d H:i')),
            'oaid_md5' => md5(date('Y-m-d H:i')),
            'os' => '0',
            'mac' => '',
            'mac1' => '',
            'ipv4' => $ipv4,
            'ipv6' => rand(1, 255).'.'.rand(1, 255).'.'.rand(1, 255).'.'.rand(1, 255).'.'.rand(1, 255).'.'.rand(1, 255),
            'ip' => $ipv4,
            'ua' => 'Mozilla/5.0 (Linux; Android 14; PJH110 Build/SP1A.'.date('Y-m-d H:i').'.016; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/126.0.6478.71 Mobile Safari/537.36',
            'geo' => '25.6x106.5x100.0',
            'ts' => '1734982170000',
            'callback_param' => 'B.jTQvB9FaAXsdi69LkdGz6v1nt4zu6YGTVSSlXpWK2FuLW0kba439qKhZeRkoP9ldUngHduqCSStFLC3LQET5P5KYiHpchvPN'.md5(date('Y-m-d H:i:s')),
            'callback_url' => 'http://ad.toutiao.com/track/activate/?callback=B.jTQvB9FaAXsdi69LkdGz6v1nt4zu6YGTVSSlXpWK2FuLW0kba439qKhZeRkoP9ldUngHduqCSStFLC3LQET5P5KYiHpchvPNGuPsm5e7'.md5(date('Y-m-d H:i:s')).'uh5viUSB&os=0&muid=',
            'model' => 'PJH110',
            'union_site' => '0',
            'caid' => '',
            'caid_md5' => '',
            'productid' => '__PRODUCTID',
            'outerid' => '',
        );

        $curl = new Httpclient();
        $curl->setHeader('Content-Type', 'application/json');
        $url = 'http://127.0.0.1:7201/v1/ad.listen/zhanshop/byte/click/CEgm1pj2JXNmnlEI1gn2JdHryzcsHbxq1huin_2BlBvDM_3D';
        $resp = $curl->request($url.'?'.http_build_query($data));
        if($resp['body']){
            $json = json_decode($resp['body'], true);
            if($json) $resp['body'] = $json;
        }
        $resp['url'] = $url;
        print_r($resp);
    }

    public function baidu()
    {
        $data = array (
            'aid' => '106017340000',
            'pid' => '6828530000',
            'uid' => '10651250000',
            'userid' => '58170000',
            'click_id' => '957b49a1_0000000',
            'idfa' => md5("a".date('Y-m-d H:i:s')),
            'imei' => md5("b".date('Y-m-d H:i:s')),
            'android_id' => md5("c".date('Y-m-d H:i:s')),
            'ip' => '2409:8907:9a4a:'.rand(0, 99999).':'.rand(0, 99999),
            'ua' => 'Mozilla/5.0 (Android 12; Mobile; rv:68.0) Gecko/68.0 Firefox/68.0',
            'os' => '2',
            'ts' => '1732087772000',
            'ext_info' => 'H-wMXD4lm1KrX-Dq0HR3nHTLPjTY0Hm3nW6dn164nsDkrjTz0H0K000000',
            'mac_md5' => 'NULL',
            'mac' => md5("d".date('Y-m-d H:i:s')),
            'oaid' => md5("q".date('Y-m-d H:i:s')),
            'oaid_md5' => 'NULL',
            'comb_id' => '__COMBID__',
            'size' => 'NULL',
            'deeplinkurl' => 'DEEPLINK_URL_',
            'bd_vid' => 'nH0LP1Dzrjn3r-'.md5(strval(time())),
            'callType' => 'v2',
            'ip_type' => 'v6',
            'interactionsType' => '1',
            'isMulti' => '1',
            'sign' => 'aeee4b2a6714c30a27800000',
        );
        $curl = new Httpclient();
        $curl->setHeader('Content-Type', 'application/json');
        $url = 'http://127.0.0.1:7201/v1/ad.listen/zhanshop/baidu/click/CEgm1pj2JXNmnlEI1gn2JdHryzcsHbxq1huin_2BlBvDM_3D';
        $resp = $curl->request($url.'?'.http_build_query($data));
        if($resp['body']){
            $json = json_decode($resp['body'], true);
            if($json) $resp['body'] = $json;
        }
        $resp['url'] = $url;
        print_r($resp);
    }

    public function honor()
    {
        $data = array (
            'advertiser_id' => '000000',
            'ad_placement_id' => '__AD_PLACEMENT_ID__',
            'campaign_id' => '10007255000',
            'creative_id' => '10007256000',
            'group_id' => '10007255000',
            'ip' => rand(1, 255).'.'.rand(1, 255).'.'.rand(1, 255).'.'.rand(1, 255),
            'oaid' => md5(date('Y-m-d H:i')),
            'os' => '0',
            'pkg_name' => 'cn.zhanshop.www',
            'request_id' => '94d3c3954e2a4cb294b08b1af0b67000',
            'sub_channel' => '__SUB_CHANNEL__',
            'trace_time' => time(),
            'track_id' => '10007256053_0fc3a8cda1d44bbaaf3f7b3bf0b9a559_94d3c39000000',
            'user_agent' => 'Dalvik/2.1.0 (Linux; U; Android 14; CMA-AN00 Build/HONORCMA-AN00)  com.hihonor.popularapps/'.md5(date('Y-m-d H:i')),
        );
        $curl = new Httpclient();
        $curl->setHeader('Content-Type', 'application/json');
        $url = 'http://127.0.0.1:7201/v1/ad.listen/zhanshop/honor/click/CEgm1pj2JXNmnlEI1gn2JdHryzcsHbxq1huin_2BlBvDM_3D';
        $resp = $curl->request($url.'?'.http_build_query($data));
        if($resp['body']){
            $json = json_decode($resp['body'], true);
            if($json) $resp['body'] = $json;
        }
        $resp['url'] = $url;
        print_r($resp);
    }
}